<template>
	<div class="">
		<el-date-picker
			@change="change"
			value-format="yyyy-MM-dd"
			v-model="value1"
			type="date"
			size="mini"
			style="width:150px"
			placeholder="选择日期"
			:readonly="readonly"
		>
		</el-date-picker>
	</div>
</template>
<script>
import moment from 'moment';
export default {
	data() {
		return {
			value1: ''
		};
	},
	props: {
		value: [String, Date],
		readonly: {
			type: [Boolean],
			default: false
		}
	},
	watch: {
		value(val) {
			this.value1 = val;
			this.$emit('input', val);
			this.$emit('change', val);
		}
	},
	mounted() {
		if (!this.value1) {
			this.value1 = moment(new Date()).format('YYYY-MM-DD');
			this.$emit('input', this.value1);
			this.$emit('change', this.value1);
		}
	},
	methods: {
		change(val) {
			this.$emit('input', val);
			this.$emit('change', val);
		}
	}
};
</script>
<style lang="stylus" scoped></style>
